package org.kumas.bigdata.hdfs3.ha;

import org.kumas.bigdata.hdfs3.rpc.RegInfo;
import org.kumas.bigdata.hdfs3.rpc.Response;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/*************************************************
 * TODO_Kumas
 *  Author： KumasZhang
 *  DateTime： 2021-12-06 10:20
 *  Description： 
 **/
public class HAService {
    private static final Map<String, RegInfo> REG_INFO_MAP = new ConcurrentHashMap<>();

    public Response registerInfo(RegInfo info) {
        REG_INFO_MAP.put(info.nodeId, info);
        System.out.println(info);
        return Response.ok(info.nodeId + " regist sucess...", null);
    }

    public Response heartbeat(String nodeId, String msg) {
        String ret = "Server received " + nodeId + " message: " + msg;
        System.out.println(ret);
        return Response.ok(msg, null);
    }
}
